#ifndef _DB_MYSQL_H_
#define _DB_MYSQL_H_

#include <mysql/mysql.h>
#include <string>
#include <errno.h>
#include <stdio.h>
#include "glog/logging.h"
#include <stdlib.h>
#include "TypeFactory.h"

using namespace std;


class MySql_DB
{
 public:
     MySql_DB(string v_strServer,string v_strUser,string v_strPassword );
     ~MySql_DB();

private:
        MYSQL       m_sql;
        MYSQL_RES  *m_pRes;
        MYSQL_ROW   m_Row;

        string  m_strServer;
        string  m_strUser;
        string  m_strPassword;

 public:
        bool ConnectToServer(string v_strDataBase);
        bool InsertToTableUser(string v_strUserName ,
                               string v_strPassword ,
                               string v_strDeviceID);
        bool JudgeLogin(string v_strUserName ,
                        string v_strPassword );

        bool GetOrder(string v_strState,ORDER_LIST &OrderList);
        bool SetOrderStateById(string v_strOrderId ,string v_strState);

        bool GetDevice(string v_strState,DEVICE_LIST &DeviceList);
        bool SetDeviceStateById(string v_strDevcieId ,string v_strState);
        bool SetDeviceConnectFdById(string v_strDevcieId ,string v_strConnectFd);
        string GetThresholdById(string v_strOrderId);
};




#endif // _DB_MYSQL_H_
